package main

import (
	"fmt"
	"log"
	"time"
)

func main() {
	ch := make(chan string, 10)
	go GenData(ch)
	go GetData02(ch)
	time.Sleep(5 * time.Second)
}

func GetData02(ch chan string) {
	for true {
		log.Println("GetData02 ", <- ch)
		time.Sleep(500 * time.Millisecond)
	}
}

func GenData(ch chan string) {
	for i := 0; i < 20; i++ {
		data := fmt.Sprintf("hello_%d", i)
		log.Printf("GenData %s\n", data)
		ch <- data
	}
}
